﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using IdentityAtRest.Contracts;
using IdentityAtRest.Service;
using IdentityAtRest.Service.WcfExtensions;

namespace ServiceHost
{
    class Program
    {
        private static WebServiceHost _host;

        static void Main(string[] args)
        {
            _host = new WebServiceHost(typeof(MonkeyShavingService), new Uri("http://localhost:8000"));

            try
            {
                _host.Description.Behaviors.Add(new ClaimsAuthServiceBehavior());

                var binding = new WebHttpBinding();
                _host.AddServiceEndpoint(typeof(IMonkeyShavingService), binding, "");

                Console.WriteLine();
                Console.WriteLine("Starting service");

                _host.Open();

                Console.WriteLine("Service started on localhost:8000");
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                _host.Abort();
                Console.WriteLine(ex);
                Console.ReadLine();
            }
        }
    }
}
